package com.ganmiao.server.supplier.service;

import com.ganmiao.server.supplier.entity.Tender;
import com.ganmiao.server.supplier.entity.TenderProduct;
import com.ganmiao.server.supplier.mapper.TenderProductMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TenderProductService {

    @Autowired
    private TenderProductMapper tenderProductMapper;
    public TenderProduct tendersProductsGet(Integer id) {
        TenderProduct tenderProduct = tenderProductMapper.tendersProductsGet(id);
        return tenderProduct;
    }

    public Integer tendersProductsInsert(TenderProduct tenderProduct) {
        int rowsAffected = tenderProductMapper.tendersProductsInsert(tenderProduct);
        return rowsAffected;
    }

    public void tendersProductsUpdate(Integer id, TenderProduct tenderProduct) {
        tenderProductMapper.tendersProductsUpdate(id,tenderProduct.getTenders_id(), tenderProduct.getProduct_id(), tenderProduct.getStatus());
    }

    public void tendersProductsDelete(Integer id) {
        if (tenderProductMapper.tendersProductsGet(id).getStatus() == 9) {
            tenderProductMapper.tendersProductsDelete(id);
        }
    }
}
